﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using GameUtils.GeneralObjects;
using GameUtils.Resources;

namespace ThouShaltNotBrick.Logic.Resources
{
    public sealed class GraphicsResources : IResourceContainer
    {
        #region Constants
        private const string TEXTURES_DIR_PATH = @"Textures\";
        private const string BRICK_STATES_DIR_PATH = TEXTURES_DIR_PATH + @"BrickStates\";

        private const string WHITE_TEXTURE_PATH = TEXTURES_DIR_PATH + "WhiteTexture";
        private const string BLACK_TEXTURE_PATH = TEXTURES_DIR_PATH + "BlackTexture";
        private const string SHADE_TEXTURE_PATH = TEXTURES_DIR_PATH + "ShadeTexture";

        private const string PAD_ASSET_PATH = "pad";
        private const string BALL_ASSET_PATH = "ball";
        private const string BRICK_NORMAL_ASSET_PATH = "brickNormal";

        private const string MENU_BUTTON_IMAGE_PATH = @"GUI\menuButton";
        #endregion

        #region Properties
        public Texture2D WhiteTexture { get; private set; }
        public Texture2D BlackTexture { get; private set; }
        public Texture2D ShadeTexture { get; private set; }

        public Texture2D PadTexture { get; private set; }
        public Texture2D BallTexture { get; private set; }
        public Texture2D BrickNormalTexture { get; private set; }

        public Texture2D MenuButtonTexture { get; private set; }

        private Dictionary<string, Texture2D> mBrickStateTextureDict;
        #endregion

        #region Overriden Methods
        public void Initialize(ContentManager pContentManager)
        {
            mBrickStateTextureDict = pContentManager.LoadContent<Texture2D>(BRICK_STATES_DIR_PATH);

            WhiteTexture = pContentManager.Load<Texture2D>(WHITE_TEXTURE_PATH);
            BlackTexture = pContentManager.Load<Texture2D>(BLACK_TEXTURE_PATH);
            ShadeTexture = pContentManager.Load<Texture2D>(SHADE_TEXTURE_PATH);

            PadTexture = pContentManager.Load<Texture2D>(PAD_ASSET_PATH);
            BallTexture = pContentManager.Load<Texture2D>(BALL_ASSET_PATH);
            BrickNormalTexture = pContentManager.Load<Texture2D>(BRICK_NORMAL_ASSET_PATH);

            MenuButtonTexture = pContentManager.Load<Texture2D>(MENU_BUTTON_IMAGE_PATH);
        }
        #endregion

        #region Methods
        public Texture2D GetBrickStateTexture(string pAssetName)
        {
            return mBrickStateTextureDict[pAssetName];
        }
        #endregion
    }
}